﻿<phone:PhoneApplicationPage 
    x:Class="CarBloke.Pages.SelectVehiclePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:valueConverters="clr-namespace:CarBloke.ValueConverters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"    
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="Root">
        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,350,0,0" Background="{StaticResource PhoneAccentBrush}" Opacity=".5">
            <Border.OpacityMask>
                <ImageBrush Stretch="Uniform" ImageSource="/Images/car.png"/>
            </Border.OpacityMask>
        </Border>
        <!--<Image Width="Auto" Height="Auto" VerticalAlignment="Bottom" Margin="0,350,0,0" Source="/Images/car2.png" Opacity=".4" />-->
        
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock x:Name="ApplicationTitle" Text="{Binding Path=Strings.ApplicationTitle, Source={StaticResource LanguageProvider}}" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock x:Name="Banner" Text="{Binding Path=Strings._vehicles, Source={StaticResource LanguageProvider}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
                <HyperlinkButton Foreground="{StaticResource PhoneAccentBrush}"  x:Name="PurchaseFullButton" HorizontalAlignment="Left" Content="{Binding Path=Strings._getfullversion, Source={StaticResource LanguageProvider}}" Click="PurchaseFullButton_Click" Visibility="Collapsed"/>
                <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" x:Name="TrailExpirationLabel" Margin="12,0,0,0" HorizontalAlignment="Left" Visibility="Collapsed"/>
            </StackPanel>

            <Canvas x:Name="ExpiredCanvas" Grid.Row="1" Background="#55AA5555" Visibility="Collapsed">
                <TextBlock Canvas.Top="350" Canvas.Left="110" Text="{Binding Path=Strings._expired, Source={StaticResource LanguageProvider}}" Style="{StaticResource PhoneTextTitle1Style}">
                    <TextBlock.RenderTransform>
                        <RotateTransform Angle="-45"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
            </Canvas>

            <!--ContentPanel - place additional content here-->
            <ListBox x:Name="LogEntryListBox" Grid.Row="1" SelectionChanged="LogEntryListBox_SelectionChanged" Margin="12,0,12,0">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0,0,0,10">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width=".15*"/>
                                <ColumnDefinition Width=".85*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <!-- Magic sauce text block because of width bug in a list box-->
                            <TextBlock Grid.ColumnSpan="3" Height="1" Text="                                                                                                                       "/>
                            <Button Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Center" Click="ItemButton_Click" Width="75" Height="75" Tag="{Binding ID}">
                                <Button.Style>
                                    <Style TargetType="Button">
                                        <Setter Property="Background" Value="Transparent"/>
                                        <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
                                        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
                                        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
                                        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
                                        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
                                        <Setter Property="Padding" Value="0"/>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid Background="Transparent">
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="CommonStates">
                                                                <VisualState x:Name="Normal"/>
                                                                <VisualState x:Name="MouseOver"/>
                                                                <VisualState x:Name="Pressed">
                                                                    <Storyboard>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ImageContainer">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Disabled">
                                                                    <Storyboard>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
                                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}">
                                                            <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                                                                <Border x:Name="ImageContainer" Background="{TemplateBinding Foreground}" Height="48" Width="48">
                                                                    <Border.OpacityMask>
                                                                        <ImageBrush ImageSource="/Images/fuelpump.png" Stretch="None"/>
                                                                    </Border.OpacityMask>
                                                                </Border>
                                                            </ContentControl>
                                                        </Border>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Button.Style>
                            </Button>
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" Style="{StaticResource PhoneTextLargeStyle}"/>
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding MostRecentFuelEfficiency}" Style="{Binding Path=MostRecentFuelEfficiencyDate, Converter={StaticResource DateTimeToTextBoxStyleConverter}}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,3"/>
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding MilesSinceLastOilChange}" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Left"/>                            
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>

    <!-- ApplicationBar -->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="appbar_newButton" IconUri="/Images/AppBar/add.png" Text="new" Click="appbar_newButton_Click"></shell:ApplicationBarIconButton>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="settingsMenuItem" Text="settings" Click="settingsMenuItem_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
